package Text1;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/*
 *@Student 张策
 */
public class text3 {
    public static void main(String[] args) {
        HashSet set=new HashSet();

        set.add(new D("a"));//ok
        set.add(new D("a")); //ok
        set.add(new String("b"));//ok
        set.add(new String("b"));//No
        for (Object o :set) {
            System.out.println(o);
        }
//        set.add("1");
//        set.add("1");
//        set.add("1");
//        Iterator integer=set.iterator();
//        for (Object o :set) {
//            System.out.println(o);
//        }

//        while (integer.hasNext()) {
//            System.out.println(integer.next());
//        }
    }
}
class D{
    private String name;

    public D(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "D{" +
                "name='" + name + '\'' +
                '}';
    }
}
